# makefile for building library

INC=../include
LIB=../lib

CC=gcc
CFLAGS=-g -Wall -I$(INC) -DCO_DEBUG -DCO_COUNT_ALLOCS
LEX=flex
YACC=bison -d -y

SLIB=$(LIB)/libcallother.a

OBJS=debug.o y.tab.o lexer.o\
	opcode.o covalue.o coint.o costring.o colist.o codict.o \
	ast.o compiler.o function.o module.o efun.o eval.o

all: clean $(SLIB)

$(SLIB): $(OBJS)
	ar rcu $@ $?
	ranlib $@

y.tab.c: grammar.y
	$(YACC) grammar.y
	mv y.tab.h $(INC)

lexer.c: lexer.l

clean:
	rm -f $(SLIB) $(OBJS)
	rm -f y.tab.c $(INC)/y.tab.h
	rm -f lexer.c

depend:
	$(CC) $(CFLAGS) -MM *.c

# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all clean depend

